﻿using System;
using System.IO;
using Microsoft.Synchronization.Files;
using mylibrary;


namespace FileSynchronizer.Objects
{
    public class FileSyncHelperClass
    {
        #region Public variables and properties
        //---------------------------------------------------------------------------------------------------------------------------------------
        public static string MetaDataFileExtension = ".SyncMetaData";
        public static string LocalApplicationDataPath = ApplicationAttributes.LocalApplicationDataPath;
        //---------------------------------------------------------------------------------------------------------------------------------------
        #endregion

        #region Public Methods
        //---------------------------------------------------------------------------------------------------------------------------------------
        public FileSyncProvider CreateFileSyncprovider(Guid ReplicaID, string Folder)
        {
            FileSyncProvider myProvider = null;
            string myMetaDataFileName = string.Concat(ReplicaID.ToString(), MetaDataFileExtension);
            string myTempPath = Path.GetTempPath();
            string myRecyclerPath = "";

            try
            {
                // Set options for the sync operation
                FileSyncOptions myOptions = FileSyncOptions.ExplicitDetectChanges | FileSyncOptions.RecycleDeletedFiles;
                FileSyncScopeFilter myFilter = new FileSyncScopeFilter();

                myProvider = new FileSyncProvider(ReplicaID, Folder, myFilter, myOptions, LocalApplicationDataPath, myMetaDataFileName, myTempPath, myRecyclerPath);
            }
            catch (Exception ex)
            {
                FormHelperClass.ProcessUnhandledException(ex, ApplicationAttributes.AssemblyProduct);
            }

            return myProvider;
        }
        //---------------------------------------------------------------------------------------------------------------------------------------
        #endregion

    }
}
